\subsection{Algebraic integers}
Recall that if \( K \) and \( L \) are fields and \( \dim_K L < \infty \), we write \( [L : K] \) for this dimension and say that \( L / K \) is a finite extension.
If \( L / K \) is a finite extension, every element \( x \in L \) is algebraic over \( K \).
\begin{definition}
    A \emph{number field} is a finite extension of \( \mathbb Q \).
\end{definition}
\begin{definition}
    Let \( L \) be a number field.
    \( \alpha \in L \) is an \emph{algebraic integer} if there exists \( f \in \mathbb Z[x] \) monic such that \( f(\alpha) = 0 \).
    We write \( \mathcal O_L = \qty{\alpha \in L \mid \alpha \text{ is an algebraic integer}} \) for the set of \emph{integers of \( L \)}.
\end{definition}
% https://q.uiver.app/?q=WzAsNCxbMCwwLCJcXG1hdGhiYiBaIl0sWzEsMCwiXFxtYXRoYmIgUSJdLFsxLDEsIkwiXSxbMCwxLCJPX0wiXSxbMCwxXSxbMSwyXSxbMCwzXSxbMywyXV0=
\[\begin{tikzcd}
	{\mathbb Z} & {\mathbb Q} \\
	{\mathcal O_L} & L
	\arrow[from=1-1, to=1-2]
	\arrow[from=1-2, to=2-2]
	\arrow[from=1-1, to=2-1]
	\arrow[from=2-1, to=2-2]
\end{tikzcd}\]
\begin{lemma}
    \( \mathcal O_{\mathbb Q} = \mathbb Z \).
\end{lemma}
\begin{proof}
    Clearly if \( \alpha \) is an integer, then \( f(x) = x - \alpha \) is a monic polynomial such that \( f(\alpha) = 0 \).
    Conversely, if \( \alpha \) is a rational number, we can let \( \alpha = \frac{r}{s} \) where \( r \) and \( s \) are coprime.
    Let \( f(x) = x^n + a_{n-1} x^{n-1} + \dots + a_0 \in \mathbb Z[x] \) such that \( f(\alpha) = 0 \).
    Clearing denominators, \( r^n + a_{n-1} r^{n-1} s + \dots + a_0 s^n = 0 \).
    Hence \( s \mid r^n \).
    If \( s \neq 1 \), let \( p \mid s \) be a prime, then \( p \mid r \), so \( r \) and \( s \) were not coprime.
\end{proof}
We will soon show that \( \mathcal O_L \) is a ring.
In other words, \( \alpha, \beta \in \mathcal O_L \) implies \( \alpha \pm \beta, \alpha \beta \in \mathcal O_L \).

Note that \( \alpha \in \mathcal O_L \) does not in general imply \( \frac{1}{\alpha} \in \mathcal O_L \).
Recall from Galois Theory that if \( \alpha, \beta \in L \), and \( \alpha, \beta \) are algebraic over \( K \), then so is \( \alpha \pm \beta, \alpha \beta \).
The proof from Galois Theory will not work in this case, since that proof does not provide for monic polynomials.
\begin{definition}
    Let \( R \subseteq S \) be commutative rings with a 1.
    \begin{enumerate}
        \item \( \alpha \in S \) is \emph{integral over \( R \)} if there exists a monic polynomial \( f \in R[x] \) such that \( f(\alpha) = 0 \).
        \item \( S \) is \emph{integral over \( R \)} if all \( \alpha \in S \) are integral over \( R \).
        \item \( S \) is \emph{finitely generated over \( R \)} if there exist elements \( \alpha_1, \dots, \alpha_n \in S \) such that any element of \( S \) can be written as an \( R \)-linear combination of the \( \alpha_i \).
        Equivalently, the map \( R^n \to S \) given by \( (r_1, \dots, r_n) \mapsto \sum_{i=1}^n r_i \alpha_i \) is surjective.
    \end{enumerate}
\end{definition}
\begin{example}
    Let \( \mathbb Q \subseteq L \) be a number field.
    Then \( \alpha \in L \) is an algebraic integer if and only if \( \alpha \) is integral over \( \mathbb Z \).
    \( \mathcal O_L \) is integral over \( \mathbb Z \) (once we have proven it is a ring).
\end{example}
If \( \alpha_1, \dots, \alpha_r \in S \), we write \( R[\alpha_1, \dots, \alpha_r] \) for the subring of \( S \) generated by \( R \) and the \( \alpha_i \).
This is equivalently the image of the polynomial ring \( R[x_1, \dots, x_r] \to S \) mapping \( x_i \) to \( \alpha_i \).
\begin{proposition}
    Let \( S = R[s] \), where \( s \) is integral over \( R \).
    Then \( S \) is finitely generated over \( R \).
    Further, if \( S = R[s_1, \dots, s_n] \) with each \( s_i \) integral over \( R \), then \( S \) is finitely generated over \( R \).
\end{proposition}
\begin{proof}
    \( S \) is spanned by \( 1, s, s^2, \dots \) over \( R \).
    By assumption, there exists \( a_0, \dots, a_{n-1} \in R \) such that \( s^n = \sum_{i=0}^{n-1} a_i s^i \).
    So the \( R \)-module spanned by \( 1, \dots, s^{n-1} \) is stable under multiplication by \( s \), so contains \( s^n, s^{n+1}, \dots \) and hence is all of \( S \).

    Let \( S_i = R[s_1, \dots, s_{i-1}] \).
    Then \( S_{i+1} = S_i[s_{i+1}] \), and \( s_{i+1} \) is integral over \( R \), hence is integral over \( S_i \).
    So \( S_{i+1} \) is finitely generated over \( S_i \).
    Note that if \( A \subseteq B \subseteq C \) where \( B \) is finitely generated over \( A \) and \( C \) is finitely generated over \( B \), then \( C \) is finitely generated over \( A \).
    Indeed, if \( b_i \) generate \( B \) over \( A \) and \( c_j \) generate \( C \) over \( B \), the \( b_i c_j \) generate \( C \) over \( A \).
\end{proof}
\begin{theorem}
    If \( S \) is finitely generated over \( R \), \( S \) is integral over \( R \).
\end{theorem}
\begin{proof}
    Let \( \alpha_1, \dots, \alpha_n \) generate \( S \) as an \( R \)-module.
    Without loss of generality, we can assume \( \alpha_1 = 1 \).
    Let \( s \in S \), and consider the function \( m_s \colon S \to S \) given by \( m_s(x) = sx \).
    Then, \( m_s(\alpha_i) = s\alpha_i = \sum b_{ij} \alpha_j \) for some choice of \( b_{ij} \).
    Let \( B = (b_{ij}) \).
    By definition, \( (sI - B) (\alpha_1, \dots, \alpha_n)^\transpose = 0 \).

    Recall that for any matrix \( X \), the adjugate has the property that \( \adj(X) X = \det X \cdot I \).
    Hence, \( \det(sI - B) (\alpha_1, \dots, \alpha_n)^\transpose = 0 \).
    In particular, \( \det(sI - B) \alpha_1 = \det(sI - B) = 0 \).
    Let \( f(t) = \det(tI - B) \), which is a monic polynomial in \( R \).
    As \( f(s) = 0 \), \( s \) is integral over \( R \).
\end{proof}
Note the similarity to a proof of the Cayley--Hamilton theorem.
Note further that this proof is constructive.
\begin{corollary}
    Let \( \mathbb Q \subseteq L \) be a number field.
    Then \( \mathcal O_L \) is a ring.
\end{corollary}
\begin{proof}
    If \( \alpha, \beta \in \mathcal O_L \), then \( \mathbb Z[\alpha, \beta] \) is finitely generated over \( \mathbb Z \).
    So this ring is integral.
\end{proof}
\begin{corollary}
    Let \( A \subseteq B \subseteq C \) be ring extensions, where \( B / A \) is integral and \( C / B \) is integral.
    Then \( C / A \) is integral.
\end{corollary}
\begin{proof}
    If \( c \in C \), let \( f(x) = \sum_{i=0}^n b_i x^i \) be the monic polynomial in \( B[x] \) it satisfies, and set \( B_0 = A[b_0, \dots, b_{n-1}] \), \( C_0 = B[c] \).
    Then \( B_0 \) is finitely generated over \( A \) as \( b_0, \dots, b_{n-1} \) are integral over \( A \), and \( C_0 \) is finitely generated over \( B_0 \) as \( c \) is integral over \( B_0 \).
    \( C_0 \) is therefore finitely generated over \( A \).
    Then the theorem implies that \( c \) is integral over \( A \).
\end{proof}
\begin{remark}
    \( C \) could have had infinitely many generators, for instance,
    \[ C = \qty{\alpha \in \mathbb C \mid \alpha \text{ is an algebraic integer}} \]
    This possibility is why we passed to \( C_0 \).
    This kind of proof is common in commutative algebra, applying a powerful theorem such as the Cayley--Hamilton theorem carefully to find its consequences.
\end{remark}
\begin{example}
    \( \mathcal O_{\mathbb Q[i]} = \mathbb Z[i] \).
\end{example}

\subsection{Minimal polynomials}
Let \( K \subseteq L \) be fields.
Recall that the minimal polynomial of \( \alpha \in L \) is the monic polynomial \( p_\alpha(x) \in K[x] \) of minimum degree such that \( p_\alpha(\alpha) = 0 \).
\begin{lemma}
    Let \( f(x) \in K[x] \) satisfy \( f(\alpha) = 0 \).
    Then \( p_\alpha \mid f \).
\end{lemma}
\begin{proof}
    By Euclid, \( f = p_\alpha h + r \) where \( r \in K[x] \) has degree less than that of \( p \).
    Then \( 0 = f(\alpha) = p_\alpha(\alpha) h(\alpha) + r(\alpha) \).
    If \( r \neq 0 \), this contradicts minimality of \( \deg p_\alpha \).
\end{proof}
The converse is obvious, so the lemma implies the uniqueness of \( p_\alpha \).
\begin{proposition}
    Let \( L \) be a number field and \( \alpha \in L \).
    Then \( \alpha \in \mathcal O_L \) if and only if \( p_\alpha(x) \in \mathbb Q[x] \) is in \( \mathbb Z[x] \).
\end{proposition}
\begin{proof}
    If \( p_\alpha \) has integer coefficients, this holds by definition.
    Conversely, suppose \( \alpha \in \mathcal O_L \), where \( p_\alpha \) is the minimal polynomial.
    Let \( M \supseteq L \) be a splitting field for \( p_\alpha \), i.e.\, a field in which \( p_\alpha \) splits into linear factors.
    Let \( h(x) \) be a monic polynomial which \( \alpha \) satisfies.
    By the lemma, \( p_\alpha \mid h \), so each root \( \alpha_i \) of \( p_\alpha \) in \( M \) is an algebraic integer.
    By the previous theorem, sums and products of algebraic integers are algebraic.
    So the coefficients of \( p_\alpha \) are algebraic integers.
    But \( p_\alpha \in \mathbb Q[x] \), so the coefficients are in \( \mathbb Z \).
\end{proof}
\begin{remark}
    One can also show this from the previous result and Gauss' lemma.
\end{remark}
\begin{lemma}
    The field of fractions of \( \mathcal O_L \) is \( L \).
    In fact, if \( \alpha \in L \), there exists \( n \in \mathbb Z, n \neq 0 \) such that \( n\alpha \in \mathcal O_L \).
\end{lemma}
\begin{proof}
    Let \( \alpha \in L \), and \( g \) be the minimal polynomial of \( \alpha \).
    Then \( g \) is monic, and there exists an integer \( n \in \mathbb Z, n \neq 0 \) such that \( ng \in \mathbb Z[x] \).
    So \( h(x) = n^{\deg g} g\qty(\frac{x}{n}) \) is an integer polynomial which is monic, and this is the minimal polynomial of \( n\alpha \), so \( n\alpha \in \mathcal O_L \).
\end{proof}

\subsection{Integral basis}
If \( L / K \) is a field extension, and \( \alpha \in L \), we write \( m_\alpha \colon L \to L \) for the map given by multiplication by \( \alpha \).
We define the \emph{norm} of \( \alpha \) to be the determinant of \( m_\alpha \), and the \emph{trace} of \( \alpha \) to be the trace of \( m_\alpha \).
Recall that if \( p_\alpha(x) \) is the minimal polynomial of \( \alpha \), then the characteristic polynomial of \( m_\alpha \) is \( \det(xI - m_\alpha) = p_\alpha^{[L/K(\alpha)]} \).
Further, if \( p_\alpha(t) \) splits as \( (t-\alpha_1)\cdots(t-\alpha_r) \) in some field \( L' \supseteq K(\alpha) \), then \( N_{K(\alpha)/K}(\alpha) = \prod \alpha_i \) and \( \Tr_{K(\alpha)/K}(\alpha) = \sum \alpha_i \), and \( N_{L/K}(\alpha) = (\prod \alpha_i)^{[L:K(\alpha)]}, \Tr_{L/K}(\alpha) = [L:K(\alpha)] \sum \alpha_i \).

If \( L \) is a number field, then \( \alpha \) is an algebraic integer if and only if the minimal polynomial is has integer coefficients, which is the case if and only if the characteristic polynomial of \( m_\alpha \) has integer coefficients.
In particular, in this case, \( N_{L/\mathbb Q}(\alpha) \in \mathbb Z \) and \( \Tr_{L/\mathbb Q}(\alpha) \in \mathbb Z \).
If the degree of \( L \) over \( \mathbb Q \) is 2, the norm and trace are integers if and only if \( \alpha \) is algebraic, since these values determine the characteristic polynomial.
\begin{example}
    Let \( L = K(\sqrt{d}) \) where \( d \in K \) is not a square.
    This has basis \( 1, \sqrt d \).
    If \( \alpha = x + y\sqrt d \), the matrix \( m_\alpha \) is
    \[ \begin{pmatrix}
        x & dy \\
        y & x
    \end{pmatrix} \]
    Then, \( \Tr_{L/K}(x+y\sqrt d) = 2x = (x+y\sqrt d) + (x-y\sqrt d) \), and \( N_{L/K}(x+y\sqrt d) = x^2 - dy^2 = (x+y\sqrt d)(x - y\sqrt d) \).
\end{example}
\begin{lemma}
    Let \( L = \mathbb Q(\sqrt{d}) \), \( d \in \mathbb Z \) a nonzero square-free integer.
    Such a field is called a \emph{quadratic field}.
    Then, \( \mathcal O_L = \mathbb Z[\sqrt d] \) if \( d \equiv 2, 3 \) mod 4, and \( \mathcal O_L = \mathbb Z\qty[\frac{1}{2}(1+\sqrt d)] \) if \( d \equiv 1 \) mod 4.
\end{lemma}
\begin{proof}
    \( x + y \sqrt d \in \mathcal O_L \) if and only if \( 2x, x^2 - dy^2 \in \mathbb Z \).
    This implies that \( 4 dy^2 \in \mathbb Z \).
    If \( y = \frac{r}{s} \) with \( \gcd(r,s) = 1 \), then \( s^2 \mid 4d \).
    But \( d \) was square-free, so \( s^2 \mid 4 \) so \( s = \pm 1, \pm 2 \).
    As \( 2x \in \mathbb Z \), we can write \( x = \frac{u}{2} \) and \( y = \frac{v}{2} \), for \( u, v \in \mathbb Z \).
    Therefore, \( u^2 - dv^2 \in 4\mathbb Z \), so \( u^2 \equiv dv^2 \) mod 4.
    Note that \( u^2 \) must be 0 or 1 mod 4.

    So if \( d \) is not congruent to 1 mod 4, \( u^2 \equiv dv^2 \) has a solution, so \( u^2, v^2 \) are both zero mod 4, so \( u, v \) are even.
    In this case, \( x, y \in \mathbb Z \), so any \( \alpha \in \mathcal O_L \) is a \( \mathbb Z \)-combination of \( 1, \sqrt d \).

    On the other hand, if \( d \equiv 1 \), then \( u, v \) have the same parity mod 2, so we can write any such values as a \( \mathbb Z \)-combination of \( 1, \frac{1}{2}(1+\sqrt d) \).
\end{proof}
\begin{example}
    If \( d = -1 \), \( \mathcal O_{\mathbb Q[i]} = \mathbb Z[i] \).
    Note that the minimal polynomial of \( \frac{1}{2}(1+\sqrt d) \) is \( t^2 - t + \frac{1}{4}(1-d) \), which has integer coefficients as \( d \equiv 1 \).
\end{example}
\begin{definition}
    Let \( L \) be a number field.
    Then, a basis \( \alpha_1, \dots, \alpha_n \) of \( L \) as a \( \mathbb Q \)-vector space is called an \emph{integral basis} if \( \mathcal O_L = \qty{\sum_{i=1}^n m_i \alpha_i \mid m_i \in \mathbb Z} = \bigoplus_{i=1}^n \mathbb Z \alpha_i \).
\end{definition}
\begin{example}
    \( \mathbb Q(\sqrt d) \) has integer basis \( 1, \frac{1}{2}(1+\sqrt d) \) or \( 1, \sqrt d \), depending on the value of \( d \) mod 4.
\end{example}
Integral bases are not unique.
Given two such bases, there exists a matrix \( g \in GL_n(\mathbb Z) \) which transforms one into the other.
We now aim to show that there exists an integral basis for every number field.

Recall that if \( L / K \) is a finite separable extension, then there exists \( \alpha \in L \) such that \( L = K(\alpha) \); this is the primitive element theorem.
Note that all extensions in characteristic 0 are separable.
\begin{example}
    \( \mathbb Q(\sqrt 2, \sqrt 3) = \mathbb Q(\sqrt 2 + \sqrt 3) \).
\end{example}
This implies that if \( L / \mathbb Q \) is a number field, then there exists \( \alpha \in L \) such that \( L = \mathbb Q(\alpha) \), isomorphic to \( \faktor{\mathbb Q[x]}{(p_\alpha(x))} \) where \( p_\alpha \) is the minimal polynomial for \( x \).
\( L \) is a field, so \( P_\alpha \vartriangleleft \mathbb Q[x] \) is a maximal ideal in the principal ideal domain \( \mathbb Q[x] \), and \( p_\alpha \) is irreducible.
Let \( \deg p_\alpha = [L:\mathbb Q] = n \).
Then \( L \) has basis \( 1, \alpha, \dots, \alpha^{n-1} \) as a \( \mathbb Q \)-vector space.
\begin{lemma}
    \( n \) is the number of field embeddings of \( L \) into \( \mathbb C \).
\end{lemma}
\begin{proof}
    \( p_\alpha \in \mathbb Q[x] \) is irreducible, so \( \gcd(p_\alpha, p_\alpha') = 1 \).
    So \( p_\alpha(x) = (x-\alpha_1)\dots(x-\alpha_n) \) has \( n \) distinct roots in \( \mathbb C \).
    A field homomorphism \( \faktor{\mathbb Q[x]}{(p_\alpha(x))} \to \mathbb C \) is automatically \( \mathbb Q \)-linear, so must map \( x \) to a root \( \alpha_i \) of \( p_\alpha(x) \) in \( \mathbb C \).
    Conversely, there exists such a map for each \( \alpha_i \), and they are distinct.
\end{proof}
This allows us to define a new invariant which refines \( n = [L:\mathbb Q] \).
\begin{definition}
    Let \( r \) be the number of real roots of \( p_\alpha(x) \), and let \( s \) be the number of complex conjugate pairs of roots of \( p_\alpha(x) \).
    Also, \( r \) is the number of field embeddings of \( L \) into \( \mathbb R \), so is independent of the choice of \( \alpha \).
    \( s \) is therefore also an invariant, as \( r + 2s = n \).
\end{definition}
\begin{lemma}
    Let \( L / \mathbb Q \) be a number field.
    Let \( \sigma_1, \dots, \sigma_n \colon L \to \mathbb C \) be the different field embeddings, so \( n = [L:\mathbb Q]\).
    If \( \beta \in L \), then \( \Tr_{L/\mathbb Q}(\beta) = \sum \sigma_i(\beta) \) and \( N_{L/\mathbb Q}(\beta) = \prod \sigma_i(\beta) \).
    We call the \( \sigma_i(\beta) \) the \emph{conjugates} of \( \beta \) in \( \mathbb C \).
\end{lemma}
\begin{example}
    If \( L = \mathbb Q(\sqrt d) \) where \( d \) is square-free, then \( a + b\sqrt d \) and \( a - b\sqrt d \) are conjugates.
\end{example}
\begin{proposition}
    Let \( L / K \) be a finite separable extension.
    Then, the \( K \)-bilinear form \( L \times L \to K \) given by \( (x, y) \mapsto \Tr_{L/K}(xy) \), known as the \emph{trace form}, is a nondegenerate inner product.
    Equivalently, if \( \alpha_1, \dots, \alpha_n \) is a basis of \( L / K \), the Gram matrix has nonzero determinant, that is, \( \Delta(\alpha_1, \dots, \alpha_n) = \det \Tr_{L/K}(\alpha_i \alpha_j) \neq 0 \).
    Conversely, if \( L / K \) is inseparable, the trace form is the zero map.
\end{proposition}
\begin{proof}
    Let \( \sigma_1, \dots, \sigma_n \colon L \to \overline K \) be the \( n \) distinct \( K \)-linear field embeddings of \( L \) into an algebraic closure \( \overline K \), which exists by separability.
    Let \( S \) be the matrix \( (\sigma_i(\alpha_j)) \).
    Observe that \( S^\transpose S \) is the matrix with \( (i,j) \) term
    \[ \sum_{k=1}^n \sigma_k(\alpha_i) \sigma_k(\alpha_j) = \sum_{k=1}^n \sigma_k(\alpha_i \alpha_j) = \Tr_{L/K}(\alpha_i \alpha_j) \]
    So \( \Delta(\alpha_1, \dots, \alpha_n) = \det S \det S^\transpose = (\det S)^2 \).
    By the primitive element theorem, there exists \( \theta \in L \) such that \( L = K(\theta) \).
    Therefore, \( 1, \theta, \dots, \theta^{n-1} \) forms a basis of \( L / K \).
    Then
    \[ S = \begin{pmatrix}
        1 & \sigma_1(\theta) & \cdots & \sigma_1(\theta^{n-1}) \\
        \vdots & \vdots & & \vdots \\
        1 & \sigma_n(\theta) & \cdots & \sigma_n(\theta^{n-1})
    \end{pmatrix} \]
    This is a Vandermonde matrix, which gives
    \[ (\det S)^2 = \prod_{i < j} \qty(\sigma_i(\theta) - \sigma_j(\theta))^2 = \Delta(1, \theta, \dots, \theta^{n-1}) \]
    This is nonzero; indeed, if \( \sigma_i(\theta) = \sigma_j(\theta) \), then \( \sigma_i(\theta^a) = \sigma_j(\theta^a) \) for all \( a \), so \( \sigma_i = \sigma_j \), but they are distinct.

    Moreover, if \( \alpha_1, \dots, \alpha_n \) is any basis of \( L / K \), and \( \alpha_1', \dots, \alpha_n' \) is another basis of \( L / K \), then
    \[ \Delta(\alpha_1', \dots, \alpha_n') = (\det A)^2 \Delta(\alpha_1, \dots, \alpha_n) \]
    where \( \alpha_i' = \sum a_{ij} \alpha_j \) and \( A = (a_{ij}) \).
    Hence, \( \Delta(\alpha_1, \dots, \alpha_n) \neq 0 \) for any basis.
\end{proof}
\begin{remark}
    \( L = K(\theta) \) and \( p_\theta(t) = \prod (t-\sigma_i(\theta)) \).
    The Galois theory notion of the discriminant of \( p_\theta \), which is \( \prod_{i < j} (\sigma_i(\theta) - \sigma_j(\theta))^2 \), is exactly the determinant of the Gram matrix \( \Delta(1, \theta, \dots, \theta^{n-1}) \), also often called a discriminant.
\end{remark}
\begin{remark}
    Let \( L \) be a number field.
    If \( \alpha, \beta \in \mathcal O_L \), \( \Tr_{L/\mathbb Q}(\alpha\beta) \in \mathbb Z \).
    Therefore, the inner product is a function \( \mathcal O_L \times \mathcal O_L \to \mathbb Z \).
    If \( \alpha_1, \dots, \alpha_n \in L \) form a basis of \( L \) over \( \mathbb Q \), and \( \alpha_1, \dots, \alpha_n \) are algebraic integers, then \( \Delta(\alpha_1, \dots, \alpha_n) \) is a nonzero integer.
\end{remark}
\begin{theorem}
    Let \( L / \mathbb Q \) be a number field.
    Then there exists an integral basis for \( \mathcal O_L \): there exist \( \alpha_1, \dots, \alpha_n \in \mathcal O_L \) such that \( \mathcal O_L = \bigoplus \mathbb Z \alpha_i \simeq \mathbb Z^n \) and \( L = \bigoplus \mathbb Q \alpha_i \simeq \mathbb Q^n \).
\end{theorem}
\begin{proof}
    Let \( \alpha_1, \dots, \alpha_n \) be any basis for \( L \) as a \( \mathbb Q \)-vector space.
    We have shown that there exists \( n_i \in \mathbb Z \) such that \( n_i \alpha_i \in \mathcal O_L \).
    Therefore, we can assume \( \alpha_1, \dots, \alpha_n \in \mathcal O_L \) without loss of generality.
    Here, \( \Delta(\alpha_1, \dots, \alpha_n) \) is a nonzero integer.

    Choose \( \alpha_1, \dots, \alpha_n \) such that \( \Delta(\alpha_1, \dots, \alpha_n) \) has minimum absolute value.
    Suppose the result is false, so let \( x \in \mathcal O_L \) and \( x = \sum \lambda_i \alpha_i \) where \( \lambda_i \in \mathbb Q \), and suppose that some \( \lambda_i \) is not an integer.
    Without loss of generality let \( \lambda_1 \not\in \mathbb Z \).
    Write \( \lambda_1 = n_1 + \varepsilon_1 \), and \( 0 < \varepsilon_1 < 1 \).
    Now, let
    \[ \alpha_1' = x - n_1 \alpha_1 = \varepsilon_1 \alpha_1 + \lambda_2 \alpha_2 + \dots + \lambda_n \alpha_n \]
    Note \( \alpha_1' \in \mathcal O_L \).
    Then \( \alpha_1', \alpha_2, \dots, \alpha_n \) is a basis of \( L \) containing only the elements of \( \mathcal O_L \).
    But \( \Delta(\alpha_1', \alpha_2, \dots, \alpha_n) = \varepsilon_1^2 \Delta(\alpha_1, \dots, \alpha_n) \) contradicting the minimality assumption.
\end{proof}
\begin{remark}
    If \( \alpha_1', \dots, \alpha_n' \) are any other integral basis of \( \mathcal O_L \), then there exists \( g \in GL_n(\mathbb Z) \) such that \( g(\alpha_i') = \alpha_i \).
    But \( \det g \in GL_1(\mathbb Z) = \qty{\pm 1} \), so \( (\det g)^2 = 1 \), giving \( \Delta(\alpha_1', \dots, \alpha_n') = \Delta(\alpha_1, \dots, \alpha_n) \), so this is an invariant.
\end{remark}
\begin{definition}
    The \emph{discriminant} of a number field \( L / \mathbb Q \) is the invariant \( D_L = \Delta(\alpha_1, \dots, \alpha_n) \).
\end{definition}
\begin{example}
    Let \( L = \mathbb Q(\sqrt{d}) \) where \( d \) is square-free.
    Then, \( d \equiv 2, 3 \) mod 4, then \( 1, \sqrt{d} \) is an integral basis.
    If \( d \equiv 1 \) mod 4, then \( 1, \frac{1}{2}\qty(1+\sqrt{d}) \) is an integral basis.
    Then,
    \[ D_L = \qty[\det \begin{pmatrix}
        1 & \sqrt{d} \\
        1 & -\sqrt{d}
    \end{pmatrix}]^2 = 4d;\quad D_L = \qty[\det \begin{pmatrix}
        1 & \frac{1}{2}\qty(1 + \sqrt{d}) \\
        1 & \frac{1}{2}\qty(1 - \sqrt{d})
    \end{pmatrix}]^2 = d \]
    So the discriminant is either \( 4d \) or \( d \).
\end{example}
\begin{remark}
    Results on quadratic fields are often phrased more uniformly if written in terms of \( D_L \).
    Note also that \( L = \mathbb Q(\sqrt{D_L}) \).
    An integral basis is \( 1, \frac{\sqrt{D_L} + D_L}{2} \) regardless of the value of \( d \).
\end{remark}
